import 'dart:ui';

class YSHHomePageCategoryModel {
  // 1.定义属性
  String? id;
  String? title;
  String? color;
  Color? cColor;
  // 2.构造方法
  YSHHomePageCategoryModel({this.id, this.title, this.color});
  // 3.工厂方法 字典转模型
  YSHHomePageCategoryModel.fromMap(Map<String, dynamic> map) {
    id = map["id"];
    title = map["title"];
    color = map["color"];
    final colorInt = int.parse(color ?? '000000', radix: 16);
    cColor = Color(colorInt | 0xFF000000);
  }

  // 4.模型转字典
  Map<String, dynamic> toMap() => {
        "id": id,
        "title": title,
        "color": color,
      };

  @override
  String toString() {
    return 'CategoryModel{id: $id, title: $title, color: $color}';
  }
}
